define(['app'],function(app){
    return {module: function($scope, $http, eventBusService, httpService, params, configService) {
            $scope.scoreList=[];

            //异动类别
            httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"0a4a1f34-91e5-4295-b816-aa1117d714fa"},function(data){
                if("0000" === data.code){
                    $scope.ydlbList = data.data;
                }else{
                    alert(data.msg);
                }
            });

            //异动原因
            httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"cff2fc10-ea39-4acf-9679-d50a425b78e5"},function(data){
                if("0000" === data.code){
                    $scope.ydyyList = data.data;
                }else{
                    alert(data.msg);
                }
            });


            //学籍状态
            httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"8a23c02c-d24a-48b6-904b-0315960f8941"},function(data){
                if("0000" === data.code){
                    $scope.xjztList = data.data;
                }else{
                    alert(data.msg);
                }
            });

            //专业
            httpService.post(app.urls.major_select,$scope.form,function(data){
                if("0000" === data.code){
                    $scope.majorList = data.data;
                }else{
                    alert(data.msg);
                }
            });


            //班级
            httpService.post(app.urls.class_select,$scope.form,function(data){
                if("0000" === data.code){
                    $scope.classList = data.data;
                }else{
                    alert(data.msg);
                }
            });



            //查询年级
            $scope.findGrade = function(){
                httpService.post(app.urls.grade_select,{fk_stage:"02030218-1e1c-4dc8-81f5-10e0ceb015a4"},function(data){
                    if("0000" === data.code){
                        $scope.gradeList = data.data;
                        $scope.find();
                    }else{
                        alert(data.msg);
                    }
                });
            }
            $scope.findGrade();


            //查询专业
            $scope.findMajor= function(){
                httpService.post(app.urls.major_select,{fk_grade:$scope.form.fk_grade},function(data){
                    if("0000" === data.code){
                        $scope.majorList = data.data;
                    }else{
                        alert(data.msg);
                    }
                });
            }

            //查询班级
            $scope.findClass= function(){
                httpService.post(app.urls.class_select,{fk_grade:$scope.form.fk_grade,fk_major:$scope.form.fk_major},function(data){
                    if("0000" === data.code){
                        $scope.classList = data.data;
                    }else{
                        alert(data.msg);
                    }
                });
            }

            //查询异动原因
            $scope.findreason = function(){
                httpService.post(app.urls.dictionary_selectOne,{"fk_rule":"cff2fc10-ea39-4acf-9679-d50a425b78e5",father_id:$scope.form.reshuffle_type},function(data){
                    if("0000" === data.code){
                        $scope.ydyyList = data.data;
                    }else{
                        alert(data.msg);
                    }
                });
            }


            $scope.find=function () {
                httpService.post(app.urls.reshuffle_selectById,{id:params.id}, function(data) {
                    if("0000" === data.code) {
                        $scope.form=data.data[0];
                    } else {
                        eventBusService.publish("modal.alert", {"content": data.msg});
                    }
                });
            }


            $scope.save=function () {
                if($scope.formCheck()){

                    httpService.post(app.urls.reshuffle_update,$scope.form,function(data) {
                        if ("0000" === data.code) {
                            eventBusService.publish("modal.alert", {"content": "修改成功"});
                            eventBusService.publish("content.page.reload", data.data);
                            eventBusService.publish("modal.page.close", {});
                        }else {
                            alert(data.msg);
                        }
                    });
                }
            }


        }
    }});